package com.baidu.project.chart12;

public class Caesear {
    public String doEncrypt(int key,String pw){

        String E = "";
        for (int i = 0; i < pw.length(); i++) {
            char c = pw.charAt(i);
            if(c >= 'a' && c <= 'z'){
                c += key % 26;
                if(c > 'z')
                    c -= 26;
                if(c < 'a')
                    c += 26;
            }
            if(c >= 'A' && c <= 'Z'){
                c += key % 26;
                if(c > 'Z')
                    c -= 26;
                if(c < 'A')
                    c += 26;
            }
            E += c;
        }
        return E;
    }
}
